package com.lyn.l_and_io

import android.app.Application
import android.util.Log
import com.lyn.io.file.FolderFactory
import com.lyn.io.sp.SpFactory
import com.tencent.mmkv.MMKV

/**
 *
 * @author longyn 2025/03/01
 * @version 1.0.0
 */
class App : Application() {


    private val TAG = "App"

    override fun onCreate() {
        super.onCreate()
        MMKV.initialize(this)
        val sp = SpFactory.create(MMKV.defaultMMKV(), "test",SpKey)
        val int = sp.getInt(SpKey.SCREEN_SAVER_TIMEOUT)
        Log.d(TAG,"gg:${int}")
        val res = sp.getString(SpKey.TEST)

        val folder = FolderFactory.create(path = filesDir.absolutePath)

        val trace = Thread.currentThread().stackTrace
        val s = StringBuilder()
        s.append(Thread.currentThread()).append("\n")
        for (traceElement in trace) {
            s.append("\t\tat $traceElement").append("\n")
        }
        Log.d("ggggg", s.toString())
        try {
            throw Throwable("")
        }catch (e:Throwable){
            folder.writeStackTrace("test.txt",e)
        }
    }
}